package dt. member;

import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import java.io.IOException;
import java.io.Reader;

public class memberIdCheckAction extends ActionSupport {
	
	public static Reader reader;  // ���� ��Ʈ���� ���� reader
	public static SqlMapClient sqlMapper; // SqlMapClient API�� ����ϱ� ���� sqlMapper ��ü
	
	private memberVO resultClass; //���� ��� ���� ������ ��ü
	
	private String id;
	private int chkId;
	
	// ����
	public memberIdCheckAction() throws IOException {
		reader = Resources.getResourceAsReader("sqlMapConfig.xml"); //sqlMapConfig.xml ������ ���������� �����´�.
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader); //sqlMapConfig.xml ������ ����� sqlMapper ��ü ��
		reader.close();
	}
	
	// Idcheck �׼�
	public String execute() throws Exception {
		//���̵� ������ ���Ѵ�
		resultClass = (memberVO) sqlMapper.queryForObject("getMember", getId());
		if(resultClass == null) {
			chkId = 0; // ���̵����, ��밡���� ���̵�
		}
		else {
			chkId = 1; // ���̵�����, ���Ұ��� ���̵�
		}
	
		return SUCCESS;
		
	}

	public static Reader getReader() {
		return reader;
	}

	public static void setReader(Reader reader) {
		memberIdCheckAction.reader = reader;
	}

	public static SqlMapClient getSqlMapper() {
		return sqlMapper;
	}

	public static void setSqlMapper(SqlMapClient sqlMapper) {
		memberIdCheckAction.sqlMapper = sqlMapper;
	}

	public memberVO getResultClass() {
		return resultClass;
	}

	public void setResultClass(memberVO resultClass) {
		this.resultClass = resultClass;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getChkId() {
		return chkId;
	}

	public void setChkId(int chkId) {
		this.chkId = chkId;
	}
	
	
}
